#!/bin/bash
local_ip=192.168.0.30
remote_ip=服务器主机
remote_port=22
remote_user=root
remote_password=服务器密码
target_port=("6379:6379" "3306:3306" "8848:8848")
for item in ${target_port[@]};do
    array=(${item//:/ })
    the_local_port=${array[0]}
    the_remote_port=${array[1]}
    sshpass -p $remote_password ssh -o ServerAliveInterval=60 -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -N -f -R $the_remote_port:$local_ip:$the_local_port $remote_user@$remote_ip -p $remote_port
done